# 初始化社团和活动数据
clubs = []
activities = []


# 主菜单函数
def show_menu():
    print("\n社团联合会管理系统")
    print("1. 添加社团")
    print("2. 查看社团列表")
    print("3. 更新社团信息")
    print("4. 删除社团")
    print("5. 添加社团活动")
    print("6. 查看活动列表")
    print("7. 退出系统")


# 添加社团函数
def add_club():
    name = input("请输入社团名称: ")
    leader = input("请输入社长姓名: ")
    member_count = int(input("请输入成员人数: "))
    description = input("请输入社团简介: ")

    club = {
        "name": name,
        "leader": leader,
        "member_count": member_count,
        "description": description
    }

    clubs.append(club)
    print(f"社团 {name} 已成功添加！")


# 查看社团列表函数
def view_clubs():
    if not clubs:
        print("暂无社团信息。")
        return

    print("\n社团列表:")
    for index, club in enumerate(clubs, 1):
        print(f"{index}. 社团名称: {club['name']}")
        print(f"   社长: {club['leader']}")
        print(f"   成员人数: {club['member_count']}")
        print(f"   社团简介: {club['description']}")
        print("-" * 30)


# 更新社团信息函数
def update_club():
    view_clubs()
    if not clubs:
        return

    choice = int(input("请选择要更新的社团编号: ")) - 1

    if 0 <= choice < len(clubs):
        club = clubs[choice]
        print(f"正在更新社团: {club['name']}")

        club['name'] = input(f"请输入新的社团名称 ({club['name']}): ") or club['name']
        club['leader'] = input(f"请输入新的社长姓名 ({club['leader']}): ") or club['leader']
        club['member_count'] = int(input(f"请输入新的成员人数 ({club['member_count']}): ") or club['member_count'])
        club['description'] = input(f"请输入新的社团简介 ({club['description']}): ") or club['description']

        print(f"社团 {club['name']} 已成功更新！")
    else:
        print("无效的社团编号！")


# 删除社团函数
def delete_club():
    view_clubs()
    if not clubs:
        return

    choice = int(input("请选择要删除的社团编号: ")) - 1

    if 0 <= choice < len(clubs):
        deleted_club = clubs.pop(choice)
        print(f"社团 {deleted_club['name']} 已成功删除！")
    else:
        print("无效的社团编号！")


# 添加社团活动函数
def add_activity():
    view_clubs()
    if not clubs:
        return

    club_choice = int(input("请选择举办活动的社团编号: ")) - 1

    if 0 <= club_choice < len(clubs):
        club = clubs[club_choice]
        activity_name = input("请输入活动名称: ")
        date = input("请输入活动日期: ")
        location = input("请输入活动地点: ")
        description = input("请输入活动简介: ")

        activity = {
            "club_name": club['name'],
            "name": activity_name,
            "date": date,
            "location": location,
            "description": description
        }

        activities.append(activity)
        print(f"社团 {club['name']} 的活动 {activity_name} 已成功添加！")
    else:
        print("无效的社团编号！")


# 查看活动列表函数
def view_activities():
    if not activities:
        print("暂无活动信息。")
        return

    print("\n社团活动列表:")
    for index, activity in enumerate(activities, 1):
        print(f"{index}. 活动名称: {activity['name']}")
        print(f"   举办社团: {activity['club_name']}")
        print(f"   日期: {activity['date']}")
        print(f"   地点: {activity['location']}")
        print(f"   活动简介: {activity['description']}")
        print("-" * 30)


# 主程序
while True:
    show_menu()
    choice = input("请输入你的选择 (1-7): ")

    if choice == "1":
        add_club()
    elif choice == "2":
        view_clubs()
    elif choice == "3":
        update_club()
    elif choice == "4":
        delete_club()
    elif choice == "5":
        add_activity()
    elif choice == "6":
        view_activities()
    elif choice == "7":
        print("感谢使用社团联合会管理系统，再见！")
        break
    else:
        print("无效的选择，请重新输入！")